import { sleep } from '@/shared/utils/helper';
import { winActions } from '@shared/utils/client';

export async function loginShowMainWindow(delay = 300, cb?: () => any) {
  winActions.setOpacity(0);
  winActions.setSize(500, 800);
  winActions.setResizable(true);
  //winActions.maximize();
  winActions.show();

  if (cb) {
    await cb();
  }
  await sleep(delay);
  winActions.center();
  winActions.setOpacity(1);
  window.focus();
  window.clientAppSdk.ipc.ipcRenderer.send('rc:app-tray', true);
}

export async function logoutShowLoginWindow(delay = 300, cb?: () => any) {
  winActions.setOpacity(0);
  winActions.setSize(350, 450);
  winActions.setResizable(false);
  winActions.minimize();
  winActions.show();
  if (cb) {
    await cb();
  }
  await sleep(delay);
  winActions.center();
  winActions.setOpacity(1);
  window.focus();
  window.clientAppSdk.ipc.ipcRenderer.send('rc:app-tray', false);
}
